package com.packet.controller;

import com.packet.pojo.Group;
import com.packet.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @ClassName:GroupController
 * @Author: mu
 * @Date:2024-06-24 14:13
 * @Describe:
 */
@Controller
public class GroupController {
    @Autowired
    GroupService groupService;

    @RequestMapping("/staff/getMyGroup")
    public String getMyGroup(Model model, HttpSession session){
        Integer sId = (Integer)session.getAttribute("sid");
        List<Group> myGroup = groupService.getMyGroup(sId);
        model.addAttribute("myGroup",myGroup);
        return "staff/Trip/myGroup";
    }

    @RequestMapping("/staff/updateMyGroup/{Iid}")
    public String update(@PathVariable int Iid,Model model,HttpSession session){
        Integer Gid = (Integer)session.getAttribute("Gid");
        groupService.updateGroup(Iid,Gid);
        return "redirect:/staff/getMyGroup";
    }
}
